java实现pptx转html在线预览 您所在的位置:网站首页 java ppt转html java实现pptx转html在线预览

java实现pptx转html在线预览

2024-06-04 22:33| 来源: 网络整理| 查看: 265

在这里插入图片描述

由于ppt中不能插入视频资源文件,但是因公司要求,在pptx中插入视频资源文件,用户将上传pptx在页面预览,因此只能是将视频插入到pptx中,然后将pptx再转换成html在浏览器进行播放,唉,公司的脑回路没办法理解,只能服从……

pom.xml引入依赖 e-iceblue spire.presentation 8.3.2 system ${basedir}/src/main/resources/lib/spire.presentation-8.3.2.jar com.e-iceblue e-iceblue https://repo.e-iceblue.cn/repository/maven-public/ org.springframework.boot spring-boot-maven-plugin true com.SoftUdiskApplication JAR

在这里插入图片描述

后端实现代码 package com.client.util; import com.spire.presentation.FileFormat; import com.spire.presentation.Presentation; /** * @author: * @creattime:2023-03-31 11:21 */ public class PPTtoHTMLUtil { public static void main(String[] args)throws Exception { //创建Presentation类的对象 Presentation ppt = new Presentation(); //加载幻灯片文档 ppt.loadFromFile("E:/test/123.pptx"); //保存为HTML格式文档到指定路径 ppt.saveToFile("E:/test/FileToHtml.html", FileFormat.HTML) ppt.dispose(); } /** * pptx转换为html * @param pptxfile:pptx文件绝对路径 * @param htmlfile:生成的html文件绝对路径 * @return */ public static boolean covertpptxToHtml(String pptxfile,String htmlfile){ boolean result=false; try { //创建Presentation类的对象 Presentation ppt = new Presentation(); //加载幻灯片文档 ppt.loadFromFile(pptxfile); //保存为HTML格式文档到指定路径 ppt.saveToFile(htmlfile, FileFormat.HTML); ppt.dispose(); result=true; }catch (Exception e){ e.printStackTrace(); result=false; } return result; } }

3.效果图 在这里插入图片描述 4.spire.presentation-8.3.2.jar下载流程 ①https://repo.e-iceblue.cn/repository/maven-public/ ②在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述

注意:一定不能低于此版本,否则报各种错,本人就引了个低版本,调试到差点吐血哇



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有